package tools;

import java.util.concurrent.CountDownLatch;

/**
 * 减
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws Exception{
        CountDownLatch countDownLatch = new CountDownLatch(6);

        for(int i = 0;i <= 5;i++){
            new Thread(() -> {
                try{
                    System.out.println(Thread.currentThread().getName()+"\t上完自习，离开教室");
                    countDownLatch.countDown();
                }catch (Exception e){
                    e.printStackTrace();
                }
            },StudentEnum.forEach_StudentEnum(i).getName()).start();
        }

        countDownLatch.await();
        System.out.println(Thread.currentThread().getName()+"\t##########班长最后关门走人");
    }
}
